﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using TextRPG.Models;
using TextRPG.Models.Skills;

namespace TextRPG.Models
{
    public class RPGInitializer : DropCreateDatabaseIfModelChanges<RPGContext>
    {
        protected override void Seed(RPGContext context)
        {
            var modifiers = new List<Modifier>
            {
                new Modifier { Name = "Damage", postfix = "Min"},
                new Modifier { Name = "Damage", postfix = "Max"},
                new Modifier { Name = "Crit"},
                new Modifier { Name = "Magic drop"},
                new Modifier { Name = "Poison", postfix = "Min"},
                new Modifier { Name = "Poison", postfix = "Max"},
                new Modifier { Name = "Fire Resistance"}
            };
            modifiers.ForEach(s => context.Modifiers.Add(s));
            context.SaveChanges();

            var itemtypes = new List<ItemType>
            {
                new ItemType { Name = "One Handed"},
                new ItemType { Name = "Two Handed"},
                new ItemType { Name = "Helmet"},
                new ItemType { Name = "Armor"},
                new ItemType { Name = "Gloves"},
                new ItemType { Name = "Coat"},
                new ItemType { Name = "Consumables"}
            };
            itemtypes.ForEach(s => context.ItemTypes.Add(s));
            context.SaveChanges();

            var itemModifierRelations = new List<ItemModifierRelation>
            {
                new ItemModifierRelation { ModifierID = 1, ItemID = 1, value = 25},
                new ItemModifierRelation { ModifierID = 5, ItemID = 2, value = 10},
                new ItemModifierRelation { ModifierID = 6, ItemID = 2, value = 15},
                new ItemModifierRelation { ModifierID = 7, ItemID = 4, value = 25},
            };
            itemModifierRelations.ForEach(s => context.ItemModifierRelations.Add(s));
            context.SaveChanges();

            var armorClasses = new List<ArmorClass>
            {
                new ArmorClass { Name = "Cloth", Heaviness = 1},
                new ArmorClass { Name = "Plate", Heaviness = 4},
                new ArmorClass { Name = "Mail", Heaviness = 3},
                new ArmorClass { Name = "Leather", Heaviness = 2}
            };
            armorClasses.ForEach(s => context.ArmorClasses.Add(s));
            context.SaveChanges();

            var damageTypes = new List<DamageType>
            {
                new DamageType { Name = "Piercing"},
                new DamageType { Name = "Blunt"},
                new DamageType { Name = "Slashing"}
            };
            damageTypes.ForEach(s => context.DamageTypes.Add(s));
            context.SaveChanges();

            var WeaponClasses = new List<WeaponClass>
            {
                new WeaponClass { Name = "Sword"},
                new WeaponClass { Name = "Hammer"},
                new WeaponClass { Name = "Axe"},
                new WeaponClass { Name = "Bow"}
            };
            WeaponClasses.ForEach(s => context.WeaponClasses.Add(s));
            context.SaveChanges();

            var weaponSubClasses = new List<WeaponSubClass>
            {
                new WeaponSubClass { Name = "Buckler"},
                new WeaponSubClass { Name = "Standard Sword"},
                new WeaponSubClass { Name = "Sledge Hammer"},
                new WeaponSubClass { Name = "War Hammer"},
                new WeaponSubClass { Name = "War Axe"},
                new WeaponSubClass { Name = "Bow"},
                new WeaponSubClass { Name = "Composite Bow"}
            };
            weaponSubClasses.ForEach(s => context.WeaponSubClasses.Add(s));
            context.SaveChanges();

            var itemDefinitions = new List<ItemDefinition>
            {
                new ItemDefinition { Name = "War Axe", ItemTypeID = 2, DamageTypeID = 3, WeaponClassID  = 3, WeaponSubClassID = 5},
                new ItemDefinition { Name = "Buckler",  ItemTypeID = 1, DamageTypeID = 1, WeaponClassID  = 1, WeaponSubClassID = 1},
                new ItemDefinition { Name = "Hat",  ItemTypeID = 3, ArmorClassID = 1},
                new ItemDefinition { Name = "Plate Coat",  ItemTypeID = 6, ArmorClassID = 2},
                new ItemDefinition { Name = "Consumable",  ItemTypeID = 7},
            };
            itemDefinitions.ForEach(s => context.ItemDefinitions.Add(s));
            context.SaveChanges();

            var items = new List<Item>
            {
                new Item { Name = "Axe", ItemDefinitionID = 1, BaseValue = 20},
                new Item { Name = "Sword", ItemDefinitionID = 2, BaseValue = 30},
                new Item { Name = "Potion", ItemDefinitionID = 5, BaseValue = 40},
                new Item { Name = "Wizard hat", ItemDefinitionID = 3, BaseValue = 10},
                new Item { Name = "Coat", ItemDefinitionID = 4, BaseValue = 5}
            };
            items.ForEach(s => context.Items.Add(s));
            context.SaveChanges();

            var Schools = new List<School>
            {
                new School { Name = "Berserker"},
                new School { Name = "Elemental"},
                new School { Name = "Ranger"},
                new School { Name = "Paladin"},
                new School { Name = "Rouge"},
                new School { Name = "Conjurer"},
            };
            Schools.ForEach(s => context.Schools.Add(s));
            context.SaveChanges();

            var Enemys = new List<Enemy>
            {
                new Enemy { Name = "Skeleton", Description = "Bony"},
                new Enemy { Name = "Crab", Description = "Bony"},
                new Enemy { Name = "Pervert", Description = "Bony"},
                new Enemy { Name = "Tiger", Description = "Bony"}
            };
            Enemys.ForEach(s => context.Enemies.Add(s));
            context.SaveChanges();

            var CharacterElements = new List<CharacterElement>
            {
                new CharacterElement { Name = "Health"},
                new CharacterElement { Name = "MaxHealth"},
                new CharacterElement { Name = "Strength"},
                new CharacterElement { Name = "Critical hit Chance"},
                new CharacterElement { Name = "Attack speed"},
                new CharacterElement { Name = "Movement Speed"},
                new CharacterElement { Name = "Inteligence"},
            };
            CharacterElements.ForEach(s => context.CharacterElements.Add(s));
            context.SaveChanges();

            var DamageTypes = new List<DamageTypeSkill>
            {
                new DamageTypeSkill { Name = "Fire"},
                new DamageTypeSkill { Name = "Holy"},
                new DamageTypeSkill { Name = "Stun"},
                new DamageTypeSkill { Name = "Wind"},
                new DamageTypeSkill { Name = "Pircing"},
                new DamageTypeSkill { Name = "Blunt"},
                new DamageTypeSkill { Name = "Poison"},
                new DamageTypeSkill { Name = "Gas"},
                new DamageTypeSkill { Name = "Resurect"},
            };
            DamageTypes.ForEach(s => context.DamageTypeSkills.Add(s));
            context.SaveChanges();

            var Targets = new List<Target>
            {
                new Target { Name = "Me"},
                new Target { Name = "All Allies"},
                new Target { Name = "All Enemies"},
                new Target { Name = "All other than me"},
                new Target { Name = "All Allies but me"},
                new Target { Name = "All Tiles"},
                new Target { Name = "All Corpse"},
                new Target { Name = "Selected Ally"},
                new Target { Name = "Selected Enemy"},
                new Target { Name = "Selected other than me"},
                new Target { Name = "Selected Allies but me"},
                new Target { Name = "Selected Tile"},
                new Target { Name = "Selected Corpse"},
                new Target { Name = "Random Ally"},
                new Target { Name = "Random Enemy"},
                new Target { Name = "Random other than me"},
                new Target { Name = "Random Allies but me"},
                new Target { Name = "Random Tile"},
                new Target { Name = "Random Corpse"},
            };
            Targets.ForEach(s => context.Targets.Add(s));
            context.SaveChanges();

            var EquipmentLimitations = new List<EquipmentLimitation>
            {
                new EquipmentLimitation { Description = "Only Cloth", ValidArmorHeavinessMin = 1, ValidArmorHeavinessMax = 1, ValidAmount = 8, InvalidArmorHeavinessMin = 2, InvalidArmorHeavinessMax = 4, EquipmentLimitationID = 1},
                new EquipmentLimitation { Description = "Half Plate, but no more than one cloth", ValidArmorHeavinessMin = 4, ValidArmorHeavinessMax = 4, ValidAmount = 4, InvalidArmorHeavinessMin = 1, InvalidArmorHeavinessMax = 1, EquipmentLimitationID = 2},
            };
            EquipmentLimitations.ForEach(s => context.EquipmentLimitations.Add(s));
            context.SaveChanges();

            var Skills = new List<Skill>
            {
                new Skill { Name = "Fireball", Description = "Fireball is awesome", SchoolID = 2, EquipmentLimitationID = 1, GetAble = true, SkillValue = 10, TargetID = 9, ManaCostMin = 10, DamageMin = 10, DamageMax = 20, DamageModifierID = 7, Chaneling = false},
            };
            Skills.ForEach(s => context.Skills.Add(s));
            context.SaveChanges();

        }
    }
}
